<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  
  <title>Hexo</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta property="og:type" content="website">
<meta property="og:title" content="Hexo">
<meta property="og:url" content="http://example.com/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:locale" content="en_US">
<meta property="article:author" content="John Doe">
<meta name="twitter:card" content="summary">
  
    <link rel="alternate" href="/atom.xml" title="Hexo" type="application/atom+xml">
  
  
    <link rel="shortcut icon" href="/favicon.png">
  
  
    
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/typeface-source-code-pro@0.0.71/index.min.css">

  
  
<link rel="stylesheet" href="/css/style.css">

  
    
<link rel="stylesheet" href="/fancybox/jquery.fancybox.min.css">

  
<meta name="generator" content="Hexo 6.2.0"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">Hexo</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://example.com"></form>
      </div>
    </div>
  </div>
</header>

      <div class="outer">
        <section id="main">
  
    <article id="post-hello-world" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
  <div class="article-meta">
    <a href="/2022/08/15/hello-world/" class="article-date">
  <time class="dt-published" datetime="2022-08-15T07:43:42.026Z" itemprop="datePublished">2022-08-15</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="p-name article-title" href="/2022/08/15/hello-world/">Hello World</a>
    </h1>
  

      </header>
    
    <div class="e-content article-entry" itemprop="articleBody">
      
        <p>Welcome to <a target="_blank" rel="noopener" href="https://hexo.io/">Hexo</a>! This is your very first post. Check <a target="_blank" rel="noopener" href="https://hexo.io/docs/">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a target="_blank" rel="noopener" href="https://hexo.io/docs/troubleshooting.html">troubleshooting</a> or you can ask me on <a target="_blank" rel="noopener" href="https://github.com/hexojs/hexo/issues">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo new <span class="string">&quot;My New Post&quot;</span></span><br></pre></td></tr></table></figure>

<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>

<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>

<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>

<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://example.com/2022/08/15/hello-world/" data-id="cl6uia2do0001vpi87073hgu1" data-title="Hello World" class="article-share-link">Share</a>
      
      
      
    </footer>
  </div>
  
</article>



  
    <article id="post-java基础" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
  <div class="article-meta">
    <a href="/2022/07/20/java%E5%9F%BA%E7%A1%80/" class="article-date">
  <time class="dt-published" datetime="2022-07-20T09:56:40.000Z" itemprop="datePublished">2022-07-20</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="p-name article-title" href="/2022/07/20/java%E5%9F%BA%E7%A1%80/">java基础</a>
    </h1>
  

      </header>
    
    <div class="e-content article-entry" itemprop="articleBody">
      
        <h1 id="java出身"><a href="#java出身" class="headerlink" title="java出身"></a>java出身</h1><p>1995年发布第一个版本</p>
<p>只有java8，java11是LTS（long term support）</p>
<h1 id="java技术体系平台"><a href="#java技术体系平台" class="headerlink" title="java技术体系平台"></a>java技术体系平台</h1><ul>
<li><p>java SE（java Standard Edition）</p>
<blockquote>
<p>面向桌面级应用</p>
</blockquote>
</li>
<li><p>java EE（java Enterprise Edition）</p>
<blockquote>
<p>针对web应用开发</p>
</blockquote>
</li>
</ul>
<h1 id="java重要特点"><a href="#java重要特点" class="headerlink" title="java重要特点"></a>java重要特点</h1><ul>
<li><p>面向对象</p>
</li>
<li><p>健壮（强类型机制、异常处理、垃圾的自动收集）</p>
</li>
<li><p>跨平台性</p>
</li>
<li><p>解释型语言</p>
</li>
</ul>
<h1 id="java运行机制与运行过程"><a href="#java运行机制与运行过程" class="headerlink" title="java运行机制与运行过程"></a>java运行机制与运行过程</h1><p>java核心机制——<strong>JVM</strong>（Java virtual machine）</p>
<p>编译指令 <code>javac -encoding GBK xxx.java</code>     .java 文件 —— 源文件        </p>
<p>运行指令 <code>java xxx</code>       .class 文件——字节码文件</p>
<p><strong>JDK</strong>（Java Development Kit）&#x3D; <strong>JRE</strong> + <strong>java开发工具</strong> [javac.exe 等编译工具]</p>
<p><strong>JRE</strong>（Java Running Evironment）&#x3D;<strong>JVM</strong> [java.exe（运行程序）] + <strong>java核心类库</strong></p>
<p>[^Java.exe]:本质上将.class 装载到jvm执行</p>
<h1 id="java开发细节"><a href="#java开发细节" class="headerlink" title="java开发细节"></a>java开发细节</h1><p>一个源文件只有一个public类。其他类的个数不限。编译后每一个类都对应一个.class</p>
<p>文件名&#x3D;&#x3D;public类</p>
<p>可以将main方法写在非public类中，然后指定运行非public类，这样入口方法就是非public的main方法</p>
<h1 id="java转译符"><a href="#java转译符" class="headerlink" title="java转译符"></a>java转译符</h1><p>\t  制表符  功能：对齐</p>
<p>\n 换行符</p>
<p>\r 一个会车</p>
<h1 id="java文档注释"><a href="#java文档注释" class="headerlink" title="java文档注释"></a>java文档注释</h1><p>&#x2F;**</p>
<ul>
<li>@author</li>
<li>@version<br>*&#x2F;<br>javadoc -d 目录 -encoding GBK -author -version xxx.java</li>
</ul>
<h1 id="java数据类型"><a href="#java数据类型" class="headerlink" title="java数据类型"></a>java数据类型</h1><p>标准数据类型</p>
<ul>
<li><p>byte 1B </p>
</li>
<li><p>short 2B</p>
</li>
<li><p>int  4B</p>
</li>
<li><p>long 8B    30000l(L)<br>浮点数&#x3D;符号位+指数位+小数位<br>浮点常数默认是double<br>对运算结果进行相等判断要小心，应是以两个数的差值的绝对值在某个精度范围内判断<br>细节：如果是直接查询得到的小数或者直接赋值是可以直接判断相等</p>
</li>
<li><p>float  4B    1.2f(F)</p>
</li>
<li><p>double 8B</p>
</li>
<li><p>char 要用‘ ‘括起来 不能用“ ”</p>
</li>
</ul>
<p>char是可以进行运算的，相当于一个整数   </p>
<blockquote>
<p>‘a’+10         107 </p>
<p>“a”+10		a10</p>
</blockquote>
<ul>
<li>布尔类型</li>
</ul>
<p>不能用0 和非0 代替true 和false</p>
<h2 id="字符编码"><a href="#字符编码" class="headerlink" title="字符编码"></a>字符编码</h2><p>ascll  1字节 	只适用于英文</p>
<p>unicode	固定2字节	存储浪费    unicode兼容ascll</p>
<p>utf-8	字母1字节	汉字3字节	可变长unicode  1-6字节</p>
<p>gbk	字母1字节	汉字2字节</p>
<p>gb2312	&lt; 	gbk</p>
<p>Big5 	繁体中文</p>
<h1 id="自动类型转换"><a href="#自动类型转换" class="headerlink" title="自动类型转换"></a>自动类型转换</h1><ol>
<li>低精度向高精度转换</li>
</ol>
<p>char—&gt;int—&gt;long—&gt;float—&gt;double</p>
<p>byte—&gt;short—&gt;int—&gt;long—&gt;float—&gt;double</p>
<ol start="2">
<li>当把精度大的数据类型赋值给精度小的数据类型，就会报错，反之</li>
</ol>
<p>系统首先将数据自动转换成容量大的数据类型</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">int</span> <span class="variable">n1</span> <span class="operator">=</span> <span class="number">10</span></span><br><span class="line"><span class="type">float</span> <span class="variable">n2</span> <span class="operator">=</span> n1 + <span class="number">1.1</span>  <span class="comment">//报错  </span></span><br><span class="line"><span class="type">float</span> <span class="variable">n3</span> <span class="operator">=</span> n1 + <span class="number">1.1f</span> </span><br><span class="line"><span class="type">double</span> <span class="variable">n4</span> <span class="operator">=</span> n1 + <span class="number">1.1</span></span><br></pre></td></tr></table></figure>

<ol start="3">
<li>（byte short） char不会自动转换；</li>
<li>单独或三者一起计算，都会转换成int</li>
</ol>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">byte</span> <span class="variable">n1</span> <span class="operator">=</span> <span class="number">1</span>；</span><br><span class="line"><span class="type">byte</span> <span class="variable">n2</span> <span class="operator">=</span> <span class="number">2</span>;</span><br><span class="line"><span class="type">short</span> <span class="variable">n3</span> <span class="operator">=</span> <span class="number">3</span>;</span><br><span class="line"><span class="type">int</span> <span class="variable">n4</span> <span class="operator">=</span> n1 + n3;</span><br><span class="line"><span class="type">byte</span> <span class="variable">n5</span> <span class="operator">=</span> n1 + n2; <span class="comment">//报错</span></span><br></pre></td></tr></table></figure>

<ol start="5">
<li>boolean 不参与类型的自动转换</li>
</ol>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">boolean</span> <span class="variable">b1</span> <span class="operator">=</span> <span class="literal">true</span>;</span><br><span class="line"><span class="type">int</span> <span class="variable">b2</span> <span class="operator">=</span> b1; <span class="comment">//报错</span></span><br></pre></td></tr></table></figure>

<ol start="5">
<li>自动提升原则：表达式结果的类型自动提升为操作数中的最大类型</li>
</ol>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">byte</span> <span class="variable">b1</span> <span class="operator">=</span> <span class="number">1</span>;</span><br><span class="line"><span class="type">short</span> <span class="variable">s1</span> <span class="operator">=</span> <span class="number">100</span>;</span><br><span class="line"><span class="type">int</span> <span class="variable">i1</span> <span class="operator">=</span> <span class="number">1</span>;</span><br><span class="line"><span class="type">float</span> <span class="variable">f1</span> <span class="operator">=</span> <span class="number">1.1F</span>;</span><br><span class="line"></span><br><span class="line"><span class="type">double</span> <span class="variable">d1</span> <span class="operator">=</span> b1 + s1 + i1 + f1;</span><br><span class="line"><span class="type">float</span> <span class="variable">d1</span> <span class="operator">=</span> b1 + s1 + i1 + f1;</span><br><span class="line"><span class="type">int</span> <span class="variable">d1</span> <span class="operator">=</span> b1 + s1 + i1 + f1; <span class="comment">//报错</span></span><br></pre></td></tr></table></figure>



<h1 id="强制类型转换"><a href="#强制类型转换" class="headerlink" title="强制类型转换"></a>强制类型转换</h1><p>long强转float会有精度丢失</p>
<ol>
<li>当进行数据的大小从   大—&gt;小 就需要使用强转</li>
<li>强转符号只针对最近的操作数有效，往往使用小括号提升优先级</li>
<li>char类型可以保存int的常量值，但不能保存int的变量值，需要强转</li>
</ol>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">char</span> <span class="variable">c1</span> <span class="operator">=</span> <span class="number">100</span>;</span><br><span class="line"><span class="type">int</span> <span class="variable">m</span> <span class="operator">=</span> <span class="number">100</span>; <span class="comment">//报错</span></span><br><span class="line"><span class="type">char</span> <span class="variable">c2</span> <span class="operator">=</span> (<span class="type">char</span>)m;</span><br></pre></td></tr></table></figure>

<ol start="4">
<li>byte short 一旦参与计算会转换成int</li>
</ol>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">enhancetype</span>&#123;</span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span>&#123;</span><br><span class="line">		<span class="type">byte</span> <span class="variable">b1</span> <span class="operator">=</span> <span class="number">10</span>;</span><br><span class="line">		<span class="type">short</span> <span class="variable">s1</span> <span class="operator">=</span> <span class="number">20</span>;</span><br><span class="line">		<span class="type">short</span> <span class="variable">s2</span> <span class="operator">=</span> s1 + b1;  <span class="comment">//错误: 不兼容的类型: 从int转换到short可能会有损失</span></span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<h1 id="string转基本类型"><a href="#string转基本类型" class="headerlink" title="string转基本类型"></a>string转基本类型</h1><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">stringToBasic</span>&#123;</span><br><span class="line">	<span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span>&#123;</span><br><span class="line">		<span class="type">int</span> <span class="variable">n1</span> <span class="operator">=</span> <span class="number">100</span>;</span><br><span class="line">		<span class="type">float</span> <span class="variable">n2</span> <span class="operator">=</span> <span class="number">1.1f</span>;</span><br><span class="line">		<span class="type">double</span> <span class="variable">n3</span> <span class="operator">=</span> <span class="number">3.4</span>;</span><br><span class="line">		<span class="type">boolean</span> <span class="variable">b1</span> <span class="operator">=</span> <span class="literal">true</span>;</span><br><span class="line"></span><br><span class="line">		<span class="type">String</span> <span class="variable">str1</span> <span class="operator">=</span> n1 + <span class="string">&quot;&quot;</span>;</span><br><span class="line">		<span class="type">String</span> <span class="variable">str2</span> <span class="operator">=</span> n2 + <span class="string">&quot;&quot;</span>;</span><br><span class="line">		<span class="type">String</span> <span class="variable">str3</span> <span class="operator">=</span> n3 + <span class="string">&quot;&quot;</span>;</span><br><span class="line">		<span class="type">String</span> <span class="variable">str4</span> <span class="operator">=</span> b1 + <span class="string">&quot;&quot;</span>;</span><br><span class="line">		System.out.println(str1 + <span class="string">&quot; &quot;</span> + str2 + <span class="string">&quot; &quot;</span> + str3 + <span class="string">&quot; &quot;</span> + str4);</span><br><span class="line"></span><br><span class="line">		<span class="type">int</span> <span class="variable">n4</span> <span class="operator">=</span> Integer.parseInt(str1);</span><br><span class="line">		<span class="type">float</span> <span class="variable">n5</span> <span class="operator">=</span> Float.parseFloat(str2);</span><br><span class="line">		<span class="type">double</span> <span class="variable">n6</span> <span class="operator">=</span> Double.parseDouble(str3);</span><br><span class="line">		<span class="type">boolean</span> <span class="variable">b2</span> <span class="operator">=</span> Boolean.parseBoolean(str4);</span><br><span class="line"></span><br><span class="line">		System.out.println(n4 + <span class="string">&quot; &quot;</span> + n5 + <span class="string">&quot; &quot;</span> + n6 + <span class="string">&quot; &quot;</span> + b2);</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>


      
    </div>
    <footer class="article-footer">
      <a data-url="http://example.com/2022/07/20/java%E5%9F%BA%E7%A1%80/" data-id="cl6uia2dm0000vpi82cn101u9" data-title="java基础" class="article-share-link">Share</a>
      
      
      
    </footer>
  </div>
  
</article>



  


</section>
        
          <aside id="sidebar">
  
    

  
    

  
    
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2022/08/">August 2022</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2022/07/">July 2022</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2022/08/15/hello-world/">Hello World</a>
          </li>
        
          <li>
            <a href="/2022/07/20/java%E5%9F%BA%E7%A1%80/">java基础</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      
      &copy; 2022 John Doe<br>
      Powered by <a href="https://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>

    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    


<script src="/js/jquery-3.4.1.min.js"></script>



  
<script src="/fancybox/jquery.fancybox.min.js"></script>




<script src="/js/script.js"></script>





  </div>
</body>
</html>